package com.gxuwz.eschool.config;

import android.graphics.Rect;
import android.view.View;

import androidx.recyclerview.widget.RecyclerView;
//设置RecyclerView的item之间的边距
public class SpacesItemDecoration extends RecyclerView.ItemDecoration {
    private int space;
    public SpacesItemDecoration(int space) {
        this.space = space;
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        outRect.top = space;
        if (parent.getChildLayoutPosition(view) != parent.getAdapter().getItemCount() - 1) {
            outRect.bottom = space;
        }
    }
}
